#ifndef _BSP_MOTOR_H
#define _BSP_MOTOR_H

#include "pinctrl.h"
#include "soc_osal.h"
#include "gpio.h"
#include "pwm_porting.h"

#define MOTOR1_GPIO_IN1 GPIO_03
#define MOTOR1_GPIO_IN2 GPIO_01
#define MOTOR2_GPIO_IN1 GPIO_10
#define MOTOR2_GPIO_IN2 GPIO_06

#define MOTOR1_GPIO_PWM GPIO_00
#define MOTOR1_PWM_CHANNEL PWM_0

#define MOTOR2_GPIO_PWM GPIO_04
#define MOTOR2_PWM_CHANNEL PWM_4

errcode_t bsp_motor_init(void);
errcode_t bsp_motor_stop(void);                  // 停止
errcode_t bsp_motor_advance(uint16_t speed);     // 前进
errcode_t bsp_motor_retreat(uint16_t speed);     // 后退
errcode_t bsp_motor_front_left(uint16_t speed);  // 左前方
errcode_t bsp_motor_front_right(uint16_t speed); // 右前方
uint32_t get_ext_clock_count(void);//获取编码器值
void pwm_out(int left, int right);
void pwm_test(pin_t pin, uint8_t pwm_x, double duty_cycle);
void encoder_init(pin_t A, pin_t B, gpio_callback_t encoder);
// void sg90_init(void);
// void sg90_angle(uint8_t angle);

#endif